#include "Light.h"


int16_t ADC_value;
double ADC_voltage;

void Show_GZ_ADC(void)
{
	HAL_ADC_Start(&hadc1);
	HAL_ADC_PollForConversion(&hadc1,10);
	ADC_value = HAL_ADC_GetValue(&hadc1);	
	ADC_voltage = (float)ADC_value * 3.3f / 4096.0;
	
	if(ADC_voltage <= 1.5 )
	{
		HAL_GPIO_WritePin(GPIOA,GPIO_PIN_2,GPIO_PIN_RESET);
	}
	else
	{
		HAL_GPIO_WritePin(GPIOA,GPIO_PIN_2,GPIO_PIN_SET);
	}
	
	OLED_Printf(0,16,OLED_8X16,"LDR:%.2f v",ADC_voltage);
	OLED_UpdateArea(0,16,128,16);
	HAL_ADC_Stop(&hadc1);
}


